package com.test.demo.algorithm.sort;

import com.test.demo.algorithm.utils.PrintTime;

import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Random;

/**
 * 排序算法
 */
public class SortClass {

    public static void main(String[] args) throws Throwable {
        //int[] array = new int[]{3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48};
        int[] array = initArray();
        int[] arrays = PrintTime.printTime(FastSort::fastSort, array, ChronoUnit.NANOS);
        //int[] arrays = PrintTime.printTime(ShellSort::shellSort2, array, ChronoUnit.NANOS);
        System.out.println(Arrays.toString(arrays));
    }

    public static int[] initArray(){
        int length=100 * 1000;
        int[] array=new int[length];
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            array[i]=random.nextInt(length);
        }
        return array;
    }
}
